﻿var NoStopCtrl = (function () {
    var that;
    var obj = function () {
        that = this;
    };

    obj.prototype = {
        jumpPage: function (pages,jumpurl) {
            if(jumpurl!=undefined && jumpurl!='' ) {
                location.href=jumpurl;
            }else{
               switch (pages) {
                    case 1://获奖攻略
                        document.ontouchmove = function () { return false; }
                        $("#prizesSoup").show();
                        break;
                    case 2://首页

                        document.ontouchmove = function () { return true; }
                        $("#logoShow1").addClass("hide");
                        $(".prizesSoup").hide();
                        $("#gradeList").hide();
                        break;
                    case 3://开始游戏
                        if(jumpurl!='') {
                            location.href=jumpurl;
                            break;
                        }else{
                            document.ontouchmove = function () { return false; }
                            $(".prizesSoup").hide();
                            $("#gradeList").hide();
                            if (document.getElementById('GameScoreLayer').style.display != 'none') {//document.getElementById('GameScoreLayer').style.display != 'none'
                                $("#GameScoreLayer").hide();
                                that.replayBtn();
                            }
                            closeWelcomeLayer();
                            break;
                        }
                    case 4:
                        document.ontouchmove = function () { return false; }
                        $("#gradeList").show();
                        $(".ranks_content").height($(".grade-content").height() - 40);
                        that.userGradeList();
                        break;
                    case 5://取消补全信息操作
                        //document.getElementById('logoShow1').style.display = 'none';
                        $("#logoShow1").addClass("hide");
                        //var k = document.getElementById('logoShow');
                        //k.className = 'logoShow32';
                        //k.style.display = 'block';
                        $("#logoShow").addClass("logoShow32");
                        $("#logoShow").css("display","block");
                        //setTimeout(function () { k.className = 'logoShow3 amshow'; }, 100);
                        //setTimeout(function () { k.className = 'logoShow3'; }, 1100);
                        setTimeout(function () { $("#logoShow").addClass("logoShow3 amshow"); }, 100);
                        setTimeout(function () { $("#logoShow").addClass("logoShow3"); }, 1100);
                        break;
                    case 6:
                        //document.getElementById('logoShow1').className = 'logoShow12';
                        $("#logoShow1").addClass("logoShow12");
                        //document.getElementById('logoShow').style.display = 'none';
                        $("#logoShow").css("display","none");
                        //document.getElementById('logoShow1').style.display = 'block';
                        //$("#logoShow1").css("display","block");
                        //setTimeout(function () { document.getElementById('logoShow1').className = 'logoShow1 amshow'; }, 100);
                        //setTimeout(function () { document.getElementById('logoShow1').className = 'logoShow1'; }, 1100);
                        setTimeout(function () { $("#logoShow1").addClass("logoShow1 amshow"); }, 100);
                        setTimeout(function () { $("#logoShow1").addClass("logoShow1"); }, 1100);
                        break;
                    case 7:
                        document.ontouchmove = function () { return false; }
                        $("#myGrade").show();
                        $(".ranks_content").height($(".grade-content").height() - 40);
                        that.userGradeList2();
                        break;
                }
            }
            
        },userGradeList:function(){

            $.ajax({
                method: "GET",
                dataType:"json",
                data: {
                    'num':20,
                },
                url: url2,
                success  : function(data) {  
                    $(".ranks_content .content").html("");
                    if(!data){
                        return;
                    }
                    for(i=0;i<data.length;i++){

                        $(".ranks_content .content").append("<li><span>"+(i+1)+"</span><span>"+data[i].username+"</span><span>"+data[i].score+"</span><span>"+data[i].ctime+"</span></li>");
                    }
                    //$(".userListSilder").css('height', data.userGradeKey.length * 25 + 'px');
                    new iScroll('userListIscroll', { vScrollbar: false, hScroll: false });

                }
            });
        },userGradeList2:function(){

            $.ajax({
                method: "GET",
                dataType:"json",
                data: {
                    'num':20,
                },
                url: url3,
                success  : function(data) {
                    $(".ranks_content2 .content").html("");
                    if(!data){
                        return;
                    }
                    for(i=0;i<data.length;i++){

                        $(".ranks_content2 .content").append("<li><span>"+(i+1)+"</span><span>"+data[i].ctime+"</span><span>"+data[i].score_member+"</span></li>");
                    }
                    //$(".userListSilder").css('height', data.userGradeKey.length * 25 + 'px');
                    new iScroll('userListIscroll2', { vScrollbar: false, hScroll: false });

                }
            });
        },
         shareText: function (data, score) {
             hideGameScoreLayer();
             //$("#share-wx").addClass("hide");
            that.score = score;
            var info = '';
            //var infos = "";

            $.ajax({
                method: "GET",
                dataType:"json",
                data: {
                    'score':score,
                },
                url: url1,
                success: function (data) {
                    if(parseInt(data.is_addressed)==0){
                        $("#logoShow1").removeClass("hide");
                    }else{
                        $("#logoShow1").addClass("hide");
                        $("#GameScoreLayer-btn").css("margin-top","10%")
                    }
                    if(parseInt(data.success)>0){
                        if (score <= 50){
                            info = "走这么慢，你的体育老师知道吗？您走了" + score + "步！超过全国20%";
                            infos="<p class='text0'>【"+info+"】 </p><p class='text2'><span id='scoreAll'>" + score + "步</span>";
                        } else if (score <= 150) {
                            info ="再快一点，太阳都下山了，您走了" + score + "步！超过全国70%";
                            infos = "<p class='text0'>【" + info + "】 </p><p class='text2'><span id='scoreAll'>" + score + "步</span>";
                        } else if (score <= 200) {
                            info = '太牛了，您的信念永不止步！您走了' + score + '步！超过全国80%';
                            infos = "<p class='text0'>【" + info + "】 </p><p class='text2'><span id='scoreAll'>" + score + "步</span>";
                        } else if (score <= 250) {
                            info = '太牛了，您的信念永不止步！您走了' + score + '步！超过全国90%';
                            infos = "<p class='text0'>【" + info + "】 </p><p class='text2'><span id='scoreAll'>" + score + "步</span>";
                        } else {
                            info = '太牛了，您的信念永不止步！您走了' + score + '步！超过全国99%';
                            infos = "<p class='text0'>【" + info + "】 </p><p class='text2'><span id='scoreAll'>" + score + "步</span>";
                        }
                        //return infos;
                    }else{
                        Util.info("请重试");
                    }
                    if(parseInt(data.is_addscore)==1){
                        $('#GameOneImg').removeClass("hide");
                    }
                }
            });
        }, replayBtn: function () {
            $("#GameScoreLayer").hide();
            //$("#logoShow1").css("display","block");
            gameRestart();
            hideGameScoreLayer();
        }, gameOver: function () {
            _gameOver = true;
            document.getElementById("stageShow").className == "";
            //$("#stageShow").removeClass("stageS1");
            clearInterval(_gameTime);
            setTimeout(function () {
                GameLayerBG.className = '';
                showGameScoreLayer();
            }, 1000);
        },  
        // userGradeList: function () {
        //         $(".userListSilder").css('height', data.userGradeKey.length * 25 + 'px');
        //         new iScroll('userListIscroll', { vScrollbar: false, hScroll: false });
        // },
          share: function () {
                //$("#logoShow1").addClass("hide");
                $("#logoShow").show();
                //document.getElementById('logoShow').className = 'logoShow3';
                $("#logoShow").addClass("logoShow3");
                $("#GameScoreLayer-text").hide();
                $("#GameOneImg").addClass("hide");
                $("#share-text").fadeIn();
                $(".kickShare").fadeIn();
                //document.getElementById('GameScoreLayer-btn').style.height = 0;
                $("#GameScoreLayer-btn").css("height","0");
                //document.getElementById('logoShow').style.marginTop = "18%";
                $("#logoShow").css("marginTop","18%");
                //document.getElementById('share-wx').style.display = 'block';
                $("#share-wx").css("display","block");
                //document.getElementById('share-wx').onclick = function () {
                $("#share-wx").click(function(){
                    $(".kickShare").hide();
                    $("#GameScoreLayer-text").show();
                    $("#share-text").hide();
                    //document.getElementById('GameScoreLayer-btn').style.height = '15%';
                    $("#GameScoreLayer-btn").css("height","15%");
                    //this.style.display = 'none';
                    $(this).css("display","none")
                    //document.getElementById('logoShow').style.marginTop = "6%";
                    $("#logoShow").css("marginTop","6%");
                });
        }
    };

    return new obj();
})();